# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.PolicySimulator.V1.Model.GoogleCloudPolicysimulatorV1ExplainedAccess do
  @moduledoc """
  Details about how a set of policies, listed in ExplainedPolicy, resulted in a certain AccessState when replaying an access tuple.

  ## Attributes

  *   `accessState` (*type:* `String.t`, *default:* `nil`) - Whether the principal in the access tuple has permission to access the resource in the access tuple under the given policies.
  *   `errors` (*type:* `list(GoogleApi.PolicySimulator.V1.Model.GoogleRpcStatus.t)`, *default:* `nil`) - If the AccessState is `UNKNOWN`, this field contains a list of errors explaining why the result is `UNKNOWN`. If the `AccessState` is `GRANTED` or `NOT_GRANTED`, this field is omitted.
  *   `policies` (*type:* `list(GoogleApi.PolicySimulator.V1.Model.GoogleCloudPolicysimulatorV1ExplainedPolicy.t)`, *default:* `nil`) - If the AccessState is `UNKNOWN`, this field contains the policies that led to that result. If the `AccessState` is `GRANTED` or `NOT_GRANTED`, this field is omitted.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :accessState => String.t() | nil,
          :errors => list(GoogleApi.PolicySimulator.V1.Model.GoogleRpcStatus.t()) | nil,
          :policies =>
            list(
              GoogleApi.PolicySimulator.V1.Model.GoogleCloudPolicysimulatorV1ExplainedPolicy.t()
            )
            | nil
        }

  field(:accessState)
  field(:errors, as: GoogleApi.PolicySimulator.V1.Model.GoogleRpcStatus, type: :list)

  field(:policies,
    as: GoogleApi.PolicySimulator.V1.Model.GoogleCloudPolicysimulatorV1ExplainedPolicy,
    type: :list
  )
end

defimpl Poison.Decoder,
  for: GoogleApi.PolicySimulator.V1.Model.GoogleCloudPolicysimulatorV1ExplainedAccess do
  def decode(value, options) do
    GoogleApi.PolicySimulator.V1.Model.GoogleCloudPolicysimulatorV1ExplainedAccess.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.PolicySimulator.V1.Model.GoogleCloudPolicysimulatorV1ExplainedAccess do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
